package com.ukao.steward.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.ukao.steward.eventbus.BatchEvent;
import com.ukao.steward.util.CheckUtils;

/**
 * Created by ukaodev on 2017/9/13.
 */

public class StringBean implements Parcelable {


    /**
     * httpCode : 200
     * msg : 请求成功
     * timestamp : 1505267478417
     */

    private String name;
    private int cnt;
    private int price;
    private int discount;
    private  String  id;
    private  String  path;
    private  int  saleType;
    private   int   clodiscount;
    private   String  srvName="";
    private   String  srvId="";
    private  String  mercBusinessId;
    private String  businessId;
    private String businessName;
    private String proTypeId;
    private  String  serviceName;
    private  String  proServiceId;
    private int amt;


    public StringBean(String  mercBusinessId, String businessId, String businessName, String proTypeId, String  id, String path, String name, int cnt,
                      int price,
                      int discount, String  srvName, String  srvId ) {
        this.mercBusinessId=mercBusinessId;
        this.businessId=businessId;
        this.businessName=businessName;
        this.proTypeId=proTypeId;
        this.id=id;
        this.path= CheckUtils.isEmptyString(path);
        this.name=name;
        this.cnt=cnt;
        this.price=price;
        this.discount=discount;
        this.srvName=srvName;
        this.srvId=srvId;
    }

    public String getServiceName() {
        return serviceName;
    }

    public String getProServiceId() {
        return proServiceId;
    }

    public String getMercBusinessId() {
        return mercBusinessId;
    }

    public String getBusinessId() {
        return businessId;
    }

    public String getBusinessName() {
        return businessName;
    }

    public String getProTypeId() {
        return proTypeId;
    }

    public String getSrvId() {
        return srvId;
    }

    public String getSrvName() {
        return srvName;
    }

    public int getSaleType() {
        return saleType;
    }

    public String getId() {
        return id;
    }

    public String getPath() {
        return path;
    }

    public static Creator<StringBean> getCREATOR() {
        return CREATOR;
    }

    public int getDiscount() {

        return discount;
    }


    public int getClodiscount() {
        return clodiscount;
    }

    private String totalAmount;


    private int httpCode;
    private String msg;
    private long timestamp;
    private String data;

    public String getData() {
        return data;
    }

    /**
     * state : true
     */


    private boolean state;

    public int getHttpCode() {


        if (httpCode == 403 || httpCode == 401) {

            BatchEvent.postNoData(BatchEvent.Message.againlogin);
        }
        return httpCode;
    }

    public void setHttpCode(int httpCode) {
        this.httpCode = httpCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }


    public boolean isState() {
        return state;
    }

    public void setState(boolean state) {
        this.state = state;
    }


    public String getName() {
        return name;
    }
    public int getAmt() {
        return amt;
    }
    public int getCnt() {
        return cnt;
    }

    public String getCnts() {
        return String.valueOf(cnt);
    }

    public int getPrice() {
        return price;
    }

    public String getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(String totalAmount) {
        this.totalAmount = totalAmount;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.name);
        dest.writeInt(this.cnt);
        dest.writeInt(this.price);
        dest.writeInt(this.discount);
        dest.writeString(this.id);
        dest.writeString(this.path);
        dest.writeInt(this.saleType);
        dest.writeInt(this.clodiscount);
        dest.writeString(this.srvName);
        dest.writeString(this.srvId);
        dest.writeString(this.mercBusinessId);
        dest.writeString(this.businessId);
        dest.writeString(this.businessName);
        dest.writeString(this.proTypeId);
        dest.writeString(this.serviceName);
        dest.writeString(this.proServiceId);
        dest.writeInt(this.amt);
        dest.writeString(this.totalAmount);
        dest.writeInt(this.httpCode);
        dest.writeString(this.msg);
        dest.writeLong(this.timestamp);
        dest.writeString(this.data);
        dest.writeByte(this.state ? (byte) 1 : (byte) 0);
    }

    protected StringBean(Parcel in) {
        this.name = in.readString();
        this.cnt = in.readInt();
        this.price = in.readInt();
        this.discount = in.readInt();
        this.id = in.readString();
        this.path = in.readString();
        this.saleType = in.readInt();
        this.clodiscount = in.readInt();
        this.srvName = in.readString();
        this.srvId = in.readString();
        this.mercBusinessId = in.readString();
        this.businessId = in.readString();
        this.businessName = in.readString();
        this.proTypeId = in.readString();
        this.serviceName = in.readString();
        this.proServiceId = in.readString();
        this.amt = in.readInt();
        this.totalAmount = in.readString();
        this.httpCode = in.readInt();
        this.msg = in.readString();
        this.timestamp = in.readLong();
        this.data = in.readString();
        this.state = in.readByte() != 0;
    }

    public static final Creator<StringBean> CREATOR = new Creator<StringBean>() {
        @Override
        public StringBean createFromParcel(Parcel source) {
            return new StringBean(source);
        }

        @Override
        public StringBean[] newArray(int size) {
            return new StringBean[size];
        }
    };
}
